package com.ym.domain.model;

import com.gitee.sunchenbin.mybatis.actable.annotation.ColumnComment;
import com.gitee.sunchenbin.mybatis.actable.annotation.ColumnType;
import com.gitee.sunchenbin.mybatis.actable.annotation.TableComment;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.time.LocalDateTime;


@Data
@Table
@TableComment("客户账户变动记录表")
@EqualsAndHashCode(callSuper = true)
public class FnAccountChangeRecord extends BaseModel {

    /**
     * 变动类型 (0-线上充值, 1-订单付款, 2-订单退款, 3-线上提现, 4-域名续费, 5-域名续费退款, 6-域名赎回, 7-域名赎回退款, 8-线下充值, 9-线下扣款)
     */
    public static final short CHANGE_TYPE_BALANCE_DEPOSIT = 0;
    public static final short CHANGE_TYPE_ORDER_PAY = 1;
    public static final short CHANGE_TYPE_ORDER_REFUND = 2;
    public static final short CHANGE_TYPE_BALANCE_WITHDRAW = 3;
    public static final short CHANGE_TYPE_DOMAIN_RENEW = 4;
    public static final short CHANGE_TYPE_DOMAIN_RENEW_REFUND = 5;
    public static final short CHANGE_TYPE_DOMAIN_REDEEM = 6;
    public static final short CHANGE_TYPE_DOMAIN_REDEEM_REFUND = 7;
    public static final short CHANGE_TYPE_OFFLINE_DEPOSIT = 8;
    public static final short CHANGE_TYPE_OFFLINE_WITHDRAW = 9;

    /**
     * 变动方向（1-入账，-1-出账）
     */
    public static final short CHANGE_DIRECTION_IN = 1;
    public static final short CHANGE_DIRECTION_OUT = -1;

    /**
     * 支付方式 (BALANCE-余额,ALIPAY-支付宝,OFFLINE-线下充值)
     */
    public static final String PAY_TYPE_BALANCE = "BALANCE";
    public static final String PAY_TYPE_ALIPAY = "ALIPAY";
    public static final String PAY_TYPE_OFFLINE = "OFFLINE";


    /**
     * 交易状态（1-成功、2-失败）
     */
    public static final short CHANGE_STATUS_SUCCESS = 1;
    public static final short CHANGE_STATUS_FAIL = 2;

    /**
     * 交易途径 (1-线上,2-线下)
     */
    public static final short TRADE_CHANNEL_ONLINE = 1;
    public static final short TRADE_CHANNEL_OFFLINE = 2;

    /**
     * 充值途径 (1-转账,2-币,9-其他)
     */
    public static final short RECHARGE_CHANNEL_TRANSFER = 1;
    public static final short RECHARGE_CHANNEL_COIN = 2;
    public static final short RECHARGE_CHANNEL_OTHER = 9;

    @Column
    @ColumnComment("订单ID")
    private Long orderId;

    @Column(length = 30)
    @ColumnComment("订单号")
    private String orderNo;

    @Column
    @ColumnComment("客户ID")
    private Integer customerId;

    @Column
    @ColumnComment("资金变动时间")
    private LocalDateTime changeTime;

    @Column
    @ColumnComment("变动类型 (0-线上充值,1-订单付款,2-订单退款,3-线上提现,4-域名续费,5-域名续费退款,6-域名赎回,7-域名赎回退款,8-线下充值,9-线下扣款)")
    private Short changeType;

    @Column
    @ColumnComment("变动方向 (1-入账,-1-出账)")
    private Short changeDirection;

    @Column
    @ColumnType(value = MySqlTypeConstant.DECIMAL, length = 18, decimalLength = 2)
    @ColumnComment("变动金额")
    private BigDecimal changeAmount;

    @Column
    @ColumnType(value = MySqlTypeConstant.DECIMAL, length = 18, decimalLength = 2)
    @ColumnComment("利润")
    private BigDecimal profit;

    @Column(length = 20)
    @ColumnComment("支付方式 (BALANCE-余额,ALIPAY-支付宝,WECHAT-微信)")
    private String payType;

    @Column(length = 100)
    @ColumnComment("交易账号(如支付宝账号、银行卡号。有则记录，没有就算了)")
    private String tradeAccount;

    @Column
    @ColumnType(value = MySqlTypeConstant.TEXT)
    @ColumnComment("备注")
    private String remark;

    @Column
    @ColumnType(value = MySqlTypeConstant.DECIMAL, length = 18, decimalLength = 2)
    @ColumnComment("操作前账户余额")
    private BigDecimal beforeBalance;

    @Column
    @ColumnType(value = MySqlTypeConstant.DECIMAL, length = 18, decimalLength = 2)
    @ColumnComment("操作后账户余额")
    private BigDecimal afterBalance;

    @Column
    @ColumnComment("交易状态 (1-成功,2-失败)")
    private Short changeStatus;

    @Column
    @ColumnType(value = MySqlTypeConstant.DECIMAL, length = 18, decimalLength = 2)
    @ColumnComment("提现金额")
    private BigDecimal refundAmount;

    @Column
    @ColumnType(value = MySqlTypeConstant.DECIMAL, length = 18, decimalLength = 2)
    @ColumnComment("提现剩余金额")
    private BigDecimal refundRemainAmount;

    @Column
    @ColumnComment("提现时间")
    private LocalDateTime refundTime;

    @Column
    @ColumnComment("是否可以退款")
    private Boolean canRefund;

    @Column
    @ColumnComment("域名id 退款时使用的")
    private Long domainId;

    @Column
    @ColumnComment("充值途径 (1-转账,2-数字货币,9-其他)")
    private Short rechargeChannel;

    @Column
    @ColumnComment("操作人ID")
    private Long operatorId;

    @Column(length = 50)
    @ColumnComment("操作人名称")
    private String operatorName;

}
